﻿<?php

// $Id$

/**
 * 应用程序启动脚本
 */

$args = array();

//判断是否有命令行变量输入
if (!isset($argv) || (count($argv) == 1 && $argv[0] == $_SERVER['SCRIPT_NAME'])) {
    echo <<<EOT
ERR: PHP running command line without \$argv.
EOT;
    exit;
}

//组织变量
foreach ($argv as $ak => $arg) {
    $argArr = explode('=', $arg);
    if (count($argArr) == 2)
        $args[$argArr[0]] = $argArr[1];
}

//判断是否有命令行变量输入
if (!isset($args['script']) || $args['script']=='') {
    echo <<<EOT
ERR: Please input the script to run.
EOT;
    exit;
}

global $g_boot_time;
$g_boot_time = microtime(true);
$app_config = require(dirname(__FILE__) . '/../config/boot.php');
require $app_config['QEEPHP_DIR'] . '/q.php';
require dirname(__FILE__) . '/cliapp.php';
$ret = CliApp::instance($app_config)->dispatching($args);
if (is_string($ret)) echo $ret;



